package javaJob.exercise.primary.array;

public class primary10 {
    public static void main(String[] args) {
        int[][] matrix = {{1,2,3},{4,5,6},{7,8,9}};
        rotate(matrix);
    }

    static void rotate(int[][] matrix) {
        int row=matrix.length;
        int col=0;
        for (int i=0;i<row;i++){
            col+=1;
        }
        for (int i=0;i<row;i++){
            for (int l=i;l<col;l++){
                if (l==i){
                    continue;
                }else {
                    int temp=matrix[i][l];
                    matrix[i][l]=matrix[l][i];
                    matrix[l][i]=temp;
                }
            }
        }
        for (int i=0;i<col/2;i++){
            for (int l=0;l<row;l++){
                int temp=matrix[l][i];
                matrix[l][i]=matrix[l][col-(i+1)];
                matrix[l][col-(i+1)]=temp;
            }
        }

        for (int i=0;i<row;i++){
            for (int l=0;l<col;l++){
                System.out.print(matrix[i][l]);
            }
            System.out.println("");
        }
    }
}
